package org.codeart.boss.controller;

import org.codeart.boss.service.CarService;
import org.codeart.boss.service.DriverUserService;
import org.codeart.common.dto.Car;
import org.codeart.common.dto.DriverUser;
import org.codeart.common.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class DriverUserController {
    
    @Autowired
    private DriverUserService driverUserService;
    
    @PostMapping("/driver-user")
    public R<Void> addDriverUser(@RequestBody DriverUser driverUser) {
        boolean b = driverUserService.addDriverUser(driverUser);
        if (b) {
            return R.ok();
        }
        return R.fail();
    }

    @PutMapping("/driver-user")
    public R<Void> updateDriverUser(@RequestBody DriverUser driverUser) {
        boolean b = driverUserService.updateDriverUser(driverUser);
        if (b) {
            return R.ok();
        }
        return R.fail();
    }
    
    @Autowired
    private CarService carService;
    
    @PostMapping("/car")
    public R<Void> addCar(@RequestBody Car car) {
        boolean b = carService.addCar(car);
        if (b) {
            return R.ok();
        }
        return R.fail();
    }
    
    @PutMapping("/car")
    public R<Void> updateCar(@RequestBody Car car) {
        
        return null;
    }

}
